import Datastore from 'nedb';
import path from 'path';
import {remote} from 'electron';

function changeDB(id) {
    const db = new Datastore({
        autoload: true,
        // 指定数据库文件路径
        filename: path.join(remote.app.getPath('userData'), `data-${id}.db`)

    })

    window.db = db
}

function debugDB() {
    window.db.find({type: 'config'}, (err, docs) => {
        console.log('debugDB', 'lastMessageId', docs)
    })
    window.db.find({type: 'conversation'}, (err, docs) => {
        console.log('debugDB', 'conversation', docs)
    })
}

export {
    changeDB,
    debugDB
}


